package com.ztools.mvp.proxy.impl;

import android.os.Bundle;

import com.ztools.mvp.IPresenter;
import com.ztools.mvp.IView;
import com.ztools.mvp.proxy.ActivityLifecycleCallback;
import com.ztools.mvp.proxy.MvpBindCallback;


/**
 * Created by zhangxuehui on 2018/3/13.
 */

public class ActivityLifecycleCallbackProxy<V extends IView, P extends IPresenter<V>> implements ActivityLifecycleCallback<V, P> {


    private MvpBindCallback<V, P> mTargetCallback;
    private MvpBindCallbackProxy<V, P> mTargetCallbackProxy;

    public ActivityLifecycleCallbackProxy(MvpBindCallback<V, P> mTargetCallback) {
        this.mTargetCallback = mTargetCallback;
    }

    public MvpBindCallbackProxy<V, P> getMvpBindCallbackProxy() {
        if (this.mTargetCallback != null) {
            this.mTargetCallbackProxy = new MvpBindCallbackProxy<>(this.mTargetCallback);
        }
        return this.mTargetCallbackProxy;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        getMvpBindCallbackProxy().newPresenter();
        getMvpBindCallbackProxy().newMvpView();
        getMvpBindCallbackProxy().attachView();
    }

    @Override
    public void onStart() {

    }

    @Override
    public void onPause() {

    }

    @Override
    public void onResume() {

    }

    @Override
    public void onRestart() {

    }

    @Override
    public void onStop() {

    }

    @Override
    public void onDestroy() {
        getMvpBindCallbackProxy().detachView();
    }
}
